#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

char* longestCommonPrefix(char** strs, int strsSize) {
    char* s0 = strs[0];
    for (int i = 0; s0[i]; i++)
    {
        for (int j = 0; j < strsSize; j++)
        {
            if (s0[i] != strs[j][i])
            {
                s0[i] = '\0';
                return s0;
            }
        }
    }
    return s0;
}

void reverse(char* s)
{
    int len = strlen(s);
    for (int i = 0; i < len / 2; i++)
    {
        char tmp = s[i];
        s[i] = s[len - i - 1];
        s[len - i - 1] = tmp;
    }
}


char* addBinary(char* a, char* b) {
    reverse(a);
    reverse(b);

    int len_a = strlen(a), len_b = strlen(b);
    int n = fmax(len_a, len_b), carry = 0, len = 0;
    char* ans = (char*)malloc(sizeof(char) * (n + 2));
    for (int i = 0; i < n; i++)
    {
        carry += i < len_a ? (a[i] == '1') : 0;
        carry += i < len_b ? (b[i] == '1') : 0;
        ans[len++] = carry % 2 + '0';
        carry /= 2;
    }

    if (carry)
    {
        ans[len++] = '1';
    }
    ans[len] = '\0';
    reverse(ans);

    return ans;
}